package com.sk.bilibili.model.diy.bottomDialog;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;

import com.sk.api.annotations.Autowired;
import com.sk.api.tool.BindTool;
import com.sk.bilibili.callBack.RequestCallBack;
import com.sk.bilibili.mapper.LookLaterMapper;
import com.sk.bilibili.model.BaseModel;
import com.sk.bilibili.other.BiliBiliProperty;
import com.sk.bilibili.other.JsonMap;
import com.sk.bilibili.utils.ClipboardUtils;
import com.sk.bilibili.utils.RequestUtils;
import com.sk.bilibili.utils.StringUtils;
import com.sk.bilibili.view.diy.bottomDialog.VideoSetBottomDialog;

public class VideoSetModel extends BaseModel<VideoSetBottomDialog>{

    @Autowired
    BiliBiliProperty property;
    @Autowired
    LookLaterMapper lookLaterMapper;

    public void shareMore(Integer videoSetId) {
        String url=generateUrl(videoSetId);
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT,url);
    }

    private String generateUrl(Integer videoSetId) {
        String baseUrl = property.getString("baseFrontUrl");
        return StringUtils.generateUrl(baseUrl,0,videoSetId);
    }

    public void copyUrl(Integer videoSetId) {
        String url = generateUrl(videoSetId);
        ClipboardUtils.setText(view.getContext(),url);
    }

    public void addLater(Integer videoSetId) {
        JsonMap map = new JsonMap();
        map.put("videoSetId",videoSetId);
        RequestUtils.process(lookLaterMapper.add(map));
    }

}